import request from '@/utils/request'
export async function policy(fileName) {
  return request({
    url:'/aliyun/oss/policy',
    method:'post',
    data: {
      fileName: fileName
    }
  }).then(res => {
    return res.data;
  })
}
/**
 * 
 * @param {{}} data 
 * @returns 
 */
export async function uploadSegment(data) {
  return request({
    url:'/aliyun/oss/uploadSegment',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  })
}

/**
 * 合并段
 * @param {{}} data 
 * @returns 
 */
export async function mergeSegment(data) {
  return request({
    url:'/aliyun/oss/mergeSegment',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  })
}

/**
 * 列举已上传段
 * @param {{}} data 
 * @returns 
 */
export async function listAlreadyUploadSegment(data) {
  return request({
    url:'/aliyun/oss/listAlreadyUploadSegment',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  })
}

/**
 * 上传分段验证文件类型
 * @param {{}} data 
 * @returns 
 */
export async function UploadSegmentParamCheckFileHeader(data) {
  return request({
    url:'/aliyun/oss/UploadSegmentParamCheckFileHeader',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  }).catch(e => e);
}

// ------------------------------------------------------------------------

export async function policyVideo(fileName) {
  return request({
    url:'/aliyun/oss/policyVideo',
    method:'post',
    data: {
      fileName: fileName
    }
  }).then(res => {
    return res.data;
  })
}
/**
 * 
 * @param {{}} data 
 * @returns 
 */
export async function uploadSegmentVideo(data) {
  return request({
    url:'/aliyun/oss/uploadSegmentVideo',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  })
}

/**
 * 合并段
 * @param {{}} data 
 * @returns 
 */
export async function mergeSegmentVideo(data) {
  return request({
    url:'/aliyun/oss/mergeSegmentVideo',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  })
}

/**
 * 列举已上传段
 * @param {{}} data 
 * @returns 
 */
export async function listAlreadyUploadSegmentVideo(data) {
  return request({
    url:'/aliyun/oss/listAlreadyUploadSegmentVideo',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  })
}

/**
 * 上传分段验证文件类型
 * @param {{}} data 
 * @returns 
 */
export async function UploadSegmentParamCheckFileHeaderVideo(data) {
  return request({
    url:'/aliyun/oss/UploadSegmentParamCheckFileHeaderVideo',
    method:'post',
    data: data
  }).then(res => {
    return res.data;
  }).catch(e => e);
}





/**
 * 
 * @param {*} file 
 * @param {*} url 
 * @returns 
 */
export async function updloadObs(file, url) {
  return request({
    url:url,
    method:'put',
    data: file
  }).then(res => {
    console.log(res);
    return res.data;
  })
}

function deleteImage(file) {
  return request({
    url:'/aliyun/oss/delete',
    method:'post',
    data: {
      fileName: file
    }
  })
}

export {deleteImage}